package com.aaa.mrcai.controller;

import com.aaa.mrcai.annotion.AAALog;
import com.aaa.mrcai.pojo.vo.RoleVO;
import com.aaa.mrcai.query.RoleQuery;
import com.aaa.mrcai.result.AjaxResult;
import com.aaa.mrcai.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:Li-Yan-Chun
 * @Date:2021/12/15 22:37
 */
@RestController
@RequestMapping("role")
public class RoleController {
    @Autowired
    private RoleService roleService;

    @RequestMapping("list")
    public AjaxResult list(RoleQuery roleQuery){
        return roleService.list(roleQuery);
    }

    @RequestMapping("getState")
    public AjaxResult getState(){
        return roleService.getState();
    }

    @RequestMapping("roleList")
    public AjaxResult roleList(){
        return roleService.roleList();
    }

    @RequestMapping("add")
    public AjaxResult add(RoleVO roleVO){
        return roleService.add(roleVO);
    }

    @RequestMapping("addPerm")
    public AjaxResult addPerm(RoleVO roleVO){
        return roleService.addPerm(roleVO);
    }

    @RequestMapping("/getOne/{id}")
    public AjaxResult getOne(@PathVariable int id){
        return roleService.getOne(id);
    }

    @RequestMapping("updateRole")
    @AAALog("修改角色")
    public AjaxResult updateRole(RoleVO roleVO){
        return roleService.updateRole(roleVO);
    }

    @RequestMapping("/deletePerm/{id}")
    public AjaxResult deletePerm(@PathVariable("id") int id){
        return roleService.deletePerm(id);
    }

    @RequestMapping("/deleteOneRole/{id}")
    public AjaxResult deleteRole(@PathVariable("id") int id){
        return roleService.deleteRole(id);
    }
}
